package com.interview.javabasic.JMM;

public class JMMAtomicDemo {
    private static volatile boolean flag = false;

    public static void main(String[] args) throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("等待数据进来");
                while(!flag){
                   // System.out.println("拿到数据开始工作了。。。。");
                }
                System.out.println("工作成功！");
            }
        }).start();
        Thread.sleep(1000);
        new Thread(new Runnable() {
            @Override
            public void run() {
                prepared();
            }
        }).start();

        }
    public static void prepared(){
         System.out.println("数据准备中。。。。。");
         flag = true;
         System.out.println("数据准备完成。");
    }
    }

